import {getHome} from "@/api/Home";
import type {Ref} from "vue";
import {ref} from "vue";

const value: Ref<any> = ref('');
const list: Ref<Array<HomeType>> = ref([]);
const list1: Ref<Array<HomeType>> = ref([]);
const list2: Ref<Array<HomeType>> = ref([]);
const list3: Ref<Array<HomeType>> = ref([]);
type HomeType = {
    onClick?: any;
    length?: number;
    styleBanner?: HomeType;
    originPrice?: string;
    activityPrice?: string;
    tag?: string;
    subTitle?: string;
    title?: string;
    id?: number;
    categoryHotSellModule?: HomeType;
    categoryName?: string;
    categoryList?: HomeType;
    targetUrl?: string;
    extra?: HomeType;
    operationResource?: HomeType;
    categoryId?: string;
    focusList?: HomeType;
    freshmanFlag?: boolean;
    indexActivityModule?: HomeType;
    kingKongModule?: HomeType;
    norColor?: string;
    background?: string;
    kingKongList?: HomeType;
    selectedColor?: string;
    policyDescList?: HomeType;
    popularItemList?: [];
    sceneLightShoppingGuideModule?: [];
    tagList?: [];
    picUrl?: string;
    schemeUrl?: string;
    text?: string;
    textColor?: any;
    desc?: string;
    icon?: string;
    styleItem?: Object;
};
export const getHomeList = () => {
    getHome()
        .then((res: any) => {
            list.value = res.data.data.data.focusList
            list1.value = res.data.data.data.kingKongModule.kingKongList
            list2.value = res.data.data.data.bigPromotionModule.floorList[0].cells
            list3.value = res.data.data.data.categoryHotSellModule
                .categoryList
            console.log(res)
        });

    function getApp() {
        location.href = 'https://m.you.163.com/downloadapp?appAwakeUrl=http%3a%2f%2fm.you.163.com'
    }

    function getPC() {
        location.href = 'https://you.163.com/?_m_forcepc_=true&_m_anonid_=68f762cc-c1f5-4a71-bebd-7a30ff13170b'
    }

    return {list, list1, list2, list3, getApp, getPC}
}
